<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>快速注册</title>
    <link  rel="stylesheet" type="text/css" href="css/reset.css" />
    <link  rel="stylesheet" type="text/css" href="css/all.css" />
    <script src="js/jquery-3.1.1.min.js"></script>
    <script src="js/self.js"></script>
</head>
<body  ontouchstart="">
<div class="detailTop pf w100 of">
    <div class="w100 of tc c3 f17"  style="background: transparent;border: none;">
        <span class="pa" style="left: 10px;font-size: 30px;color: #444444;" onclick="javascript:history.back();">&laquo;</span>
        快速注册
    </div>
</div>

<div class="container db jz">
    <section class="w100 h100">
        <section class="loginBlock w100 db" style="margin-top: 28%">
            <div>
                <input type="tel" name="tel" value="" placeholder="请输入手机号" required="required" id="registTel"/>
            </div>
            <div class="clearfix of" style="border: none">
                <input type="text" name="pwd" value="" placeholder="请输入验证码" required="required" id="verificationCode" style="width: 41%;float: left;border-bottom: 1px solid #DEDEDE;"/>
                <button id="verificationCodeGet" class="f16 cf tc fr" onclick="settime($('#verificationCodeGet'),$('#registTel'))">获取验证码</button>
            </div>
            <div>
                <input type="password" name="pwd" value="" placeholder="请输入您的密码" required="required" id="password"/>
            </div>
            <div>
                <input type="password" name="pwd" value="" placeholder="请再次输入您的密码" required="required" id="password2"/>
            </div>
            <div style="border: none">
                <button type="button" id="loginBub" class="f18 cf tc w100" style="margin-top: 32px;">快速注册</button>
            </div>
        </section>
    </section>
</div>
<div class="theme-popover-mask">
    <div class="w100 h100 of">
        <img src="images/loading.gif" class="jz hauto db" style="margin-top: 66%;width: 32px"/>
    </div>
</div>
<script>
    //倒计时
    var countdown=60;
    function resetCode(btn) {
        if (countdown == 0) {
            btn.removeAttr("disabled");
            btn.text("重新获取验证码");
            countdown = 60;
            return;

        } else {
            btn.attr("disabled", "disabled");
            btn.text("请在" + countdown + "s内填写");
            countdown--;
        }
        setTimeout(function() { resetCode(btn); },1000);
    }

    //发送验证码
    function smsSend(tel) {
        var phone =$.trim(tel);
        $.ajax({
            url: "",
            data: {"mobile": phone},
            type: 'get',
            dataType: 'json',
            beforeSend: function () {
            },
            success: function (data) {
                console.log(data);
                if (data.code == 200) {
                    alert('验证码发送成功,请注意查收!');
                } else {
                    alert(data.msg);
                }
            },
            error: function () {
                alert(data.msg);
                alert('网络忙，请重试');
            },
            complete: function () {
            }
        });
    }

    //验证手机号码
    function checkPhone(tel) {
        var pattern = /^1[0-9]{10}$/;
        var phone =$.trim(tel);
        isPhone = 1;
        if (phone == '') {
            alert("请输入手机号码!");
            isPhone = 0;
            return false;
        }
        if (!pattern.test(phone)) {
            alert("请输入正确的手机号码!");
            isPhone = 0;
            return false;
        }
        if(pattern.test(phone)){
            return true;
        }

    }
    /*获取验证码*/
    var isPhone = 1;
    function settime(btn,tel){
        var phone= tel.val();
        if(checkPhone(phone)){
            resetCode(btn); //倒计时
            smsSend(phone);
        }else{
            tel.focus();
        }
    }
    $(function () {
        $('#loginBub').click(function () {
            var tel =$.trim($('#registTel').val());
            var password = $.trim($('#password').val());
            var password2 = $.trim($('#password2').val());
            var verificationCode = $.trim($('#verificationCode').val());

            if(tel== ""){
                alert("你还未填写手机号");
                return false;
            }
            if(verificationCode== ""){
                alert("你还未填写验证码");
                return false;
            }
            if(password == ""||password2 == ""){
                alert("请输入密码!");
                return false;
            }

            $.ajax({
                url: "",
                data: {tel: tel, password: password},
                type: 'post',
                dataType: 'json',
                beforeSend: function () {
                    $('.theme-popover-mask').show();
                },
                success: function (data) {
                    console.log(data);
                    if (data.code == 200) {
//                        alert("您的申请已提交,等待审核");
//                        alert(data.msg);
//                        window.location.reload();
//                        location.href = "withdraw.html";
                    }else{
//                        alert(data.msg);
                        //window.history.back(-1);
                    }
                },
                error: function (data) {
                    alert(data.msg);
                    return false;
                },
                complete: function () {
                    alert("注册成功，前去登录");
                    $('.theme-popover-mask').hide();
                    location.href = "login.html";
                }
            });
        })

    })

</script>

</body>
</html>
</html>
</html>
</html>